package cn.com.hori.cms.model;

import java.io.Serializable;

/**
 * 公共返回类对象 用来包裹返回信息
 *
 * @author 刘艺
 * @date 2018/3/8 9:42
 */
public class CommonResponse<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 请求成功
     */
    public static final int SUCCESS_CODE = 2000;

    /**
     * 用户未被授权
     */
    public static final int NOT_AUTHORIZED_CODE = 9001;
    /**
     * 未授权提示信息
     */
    public static final String NOT_AUTHORIZED_MSG = "用户未被授权";
    /**
     * 用户授权失效
     */
    public static final int TOKEN_NOT_AVAILABLE_CODE = 9002;
    /**
     * 授权失效提示信息
     */
    public static final String TOKEN_NOT_AVAILABLE_MSG = "用户授权失效或不可用";

    /**
     * 登录失败
     */
    public static final int LOGIN_FAIL_CODE = 9003;
    /**
     * 登录失败
     */
    public static final String LOGIN_FAIL_MSG = "用户名或密码错误";

    /**
     * 其他失败
     */
    public static final int OTHER_FAIL_CODE = 9999;


    private String msg = "success";

    private int code = SUCCESS_CODE;

    private T body;

    public CommonResponse() {
        super();
    }

    public CommonResponse(T body) {
        super();
        this.body = body;
    }

    public CommonResponse(int code, String msg) {
        super();
        this.code = code;
        this.msg = msg;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public T getBody() {
        return body;
    }

    public void setBody(T body) {
        this.body = body;
    }
}